package yang.model;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * HospitalUser entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "hospital_user", catalog = "hospital", uniqueConstraints = @UniqueConstraint(columnNames = "user_nicheng"))
public class HospitalUser implements java.io.Serializable {

	// Fields

	private Integer userNo;//自增
	private HospitalOffice hospitalOffice;//关联的办公室，如果没有不会再也没上显示
	private String userTruename;//真实姓名，在页面上会做验证必须输入中文
	private String userNicheng;//用户昵称，登录名称
	private Double userPrice;//只有医生角色有
	private String userPwd;//密码，以MD5加密
	private String userRole;//用户角色
	private Set<PatientInfo> patientInfos = new HashSet<PatientInfo>(0);

	// Constructors

	/** default constructor */
	public HospitalUser() {
	}

	/** full constructor */
	public HospitalUser(HospitalOffice hospitalOffice, String userTruename,
			String userNicheng, Double userPrice, String userPwd,
			String userRole, Set<PatientInfo> patientInfos) {
		this.hospitalOffice = hospitalOffice;
		this.userTruename = userTruename;
		this.userNicheng = userNicheng;
		this.userPrice = userPrice;
		this.userPwd = userPwd;
		this.userRole = userRole;
		this.patientInfos = patientInfos;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "user_no", unique = true, nullable = false)
	public Integer getUserNo() {
		return this.userNo;
	}

	public void setUserNo(Integer userNo) {
		this.userNo = userNo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_office")
	public HospitalOffice getHospitalOffice() {
		return this.hospitalOffice;
	}

	public void setHospitalOffice(HospitalOffice hospitalOffice) {
		this.hospitalOffice = hospitalOffice;
	}

	@Column(name = "user_truename", length = 20)
	public String getUserTruename() {
		return this.userTruename;
	}

	public void setUserTruename(String userTruename) {
		this.userTruename = userTruename;
	}

	@Column(name = "user_nicheng", unique = true, length = 12)
	public String getUserNicheng() {
		return this.userNicheng;
	}

	public void setUserNicheng(String userNicheng) {
		this.userNicheng = userNicheng;
	}

	@Column(name = "user_price", precision = 22, scale = 0)
	public Double getUserPrice() {
		return this.userPrice;
	}

	public void setUserPrice(Double userPrice) {
		this.userPrice = userPrice;
	}

	@Column(name = "user_pwd", length = 32)
	public String getUserPwd() {
		return this.userPwd;
	}

	public void setUserPwd(String userPwd) {
		this.userPwd = userPwd;
	}

	@Column(name = "user_role", length = 200)
	public String getUserRole() {
		return this.userRole;
	}

	public void setUserRole(String userRole) {
		this.userRole = userRole;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "hospitalUser")
	public Set<PatientInfo> getPatientInfos() {
		return this.patientInfos;
	}

	public void setPatientInfos(Set<PatientInfo> patientInfos) {
		this.patientInfos = patientInfos;
	}

}